package com.ruoyi.auth.service;

import com.ruoyi.auth.api.IUserLoginInfoApiService;
import com.ruoyi.common.core.exception.BaseException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class UserLoginInfoServiceImpl {

    @Resource
    private Map<String, IUserLoginInfoApiService> authUserApiServiceMap = new ConcurrentHashMap<>(3);

    // userCategory 用户类目   system(系统)  user(会员) merchant（商户）
    public IUserLoginInfoApiService getUserApiService(String userCategory) {
        userCategory = userCategory == null ? "system" : userCategory;
        userCategory = userCategory.substring(0, 1).toUpperCase() + userCategory.substring(1);
        userCategory+="UserLoginService";
//        this.userCategory = userCategory;
        if (authUserApiServiceMap.get(userCategory) != null) {
            return authUserApiServiceMap.get(userCategory);
        } else {
           throw new BaseException(userCategory+"类别未找到");
        }
    }
}
